import { reqIndexData } from '../../api/index'
Page({
  //初始化数据
  data: {
    bannerList: [], //轮播图数据
    categoryList: [], //商品导航数据
    activeList: [], //活动渲染区域
    hotList: [], //人气推荐
    guessList: [], //猜你喜欢
    loading: true //是否显示骨架屏 ,默认显示
  },
  //获取首页数据
  async getIndexData() {
    //获取数据
    //运用promise.all 返回数组,根据接口调用顺序进行返回
    const res = await reqIndexData()
    this.setData({
      bannerList: res[0].data,
      categoryList: res[1].data,
      activeList: res[2].data,
      hotList: res[3].data,
      guessList: res[4].data,
      loading: false
    })
  },
  //监听页面加载
  onLoad() {
    this.getIndexData()
  },
  //转发功能
  onShareAppMessage() {
    return {
      title: '很想很想再次见到你',
      path: '/pages/index/index',
      imageUrl: '../.../../../../../../assets/images/love.jpg'
    }
  },

  //把小程序分享朋友圈
  onShareTimeline() {}
})
